using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VBSGROE
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "TST":
                case "UBT":
                case "SXN":
                default:
                    #region=========
                    dwReturn["BSGMANDANT"] = "00";
                    dwReturn["BSGART"] = "S3-2024             ";
                    dwReturn["BSGMTYP"] = "02      ";
                    dwReturn["BSGLFD"] = "1";
                    dwReturn["BSGAENDZL"] = "0";
                    dwReturn["BSGAENDBEN"] = "CAD     ";
                    dwReturn["BSGAENDDAT"] = "20140818";
                    dwReturn["BSGNEUBEN"] = "CAD     ";
                    dwReturn["BSGNEUDAT"] = "20140818";
                    dwReturn["BSGKETTART"] = "02    ";
                    dwReturn["BSGMAXLG"] = "5000000";
                    dwReturn["BSGMAXGW"] = "340";
                    dwReturn["BSGLOS"] = "4";
                    dwReturn["BSGANZTB"] = "0";
                    dwReturn["BSGLLEIST"] = "    ";
                    dwReturn["BSGRLEIST"] = "    ";
                    dwReturn["BSGFILLER"] = "                                    ";

                    #endregion
                    break;
                case "JLT":
                    dwReturn["BSGMANDANT"] = "00";
                    dwReturn["BSGART"] = "S3-2024             ";
                    dwReturn["BSGMTYP"] = "02      ";
                    dwReturn["BSGLFD"] = "1";
                    dwReturn["BSGAENDZL"] = "0";
                    dwReturn["BSGAENDBEN"] = "CAD     ";
                    dwReturn["BSGAENDDAT"] = "20140818";
                    dwReturn["BSGNEUBEN"] = "CAD     ";
                    dwReturn["BSGNEUDAT"] = "20140818";
                    dwReturn["BSGKETTART"] = "02    ";
                    dwReturn["BSGMAXLG"] = "5000000";
                    dwReturn["BSGMAXGW"] = "340";
                    dwReturn["BSGLOS"] = "4";
                    dwReturn["BSGANZTB"] = "0";
                    dwReturn["BSGLLEIST"] = "    ";
                    dwReturn["BSGRLEIST"] = "    ";
                    dwReturn["BSGFILLER"] = "                                    ";

                    break;
            }
        }

        public void InsertBSGROE(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                case "YGR":
                case "TST":
                case "UBT":
                case "SXN":
                default:
                    or1.CommandText = "INSERT INTO BSGROE ( BSGMANDANT,BSGART,BSGMTYP,BSGLFD,BSGAENDZL,BSGAENDBEN,BSGAENDDAT,BSGNEUBEN,BSGNEUDAT,BSGKETTART,BSGMAXLG,BSGMAXGW,BSGLOS,BSGANZTB,BSGLLEIST,BSGRLEIST,BSGFILLER)"
                    + " VALUES (:BSGMANDANT:,:BSGART:,:BSGMTYP:,:BSGLFD:,:BSGAENDZL:,:BSGAENDBEN:,:BSGAENDDAT:,:BSGNEUBEN:,:BSGNEUDAT:,:BSGKETTART:,:BSGMAXLG:,:BSGMAXGW:,:BSGLOS:,:BSGANZTB:,:BSGLLEIST:,:BSGRLEIST:,:BSGFILLER:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
                    break; 
            } 
            Connect2Proxy(or1);
        }
        public DataSet QBSGROE01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART: AND BSGMTYP =:BSGMTYP: AND BSGLFD=:BSGLFD: ";
             or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult=Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBSGROE02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART: AND BSGMTYP =:BSGMTYP:   ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBSGROE03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBSGROE04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT BSGKETTART AS KEY,M.* FROM  BSGROE M"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBSGROE05(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART: AND BSGMTYP =:BSGMTYP:   ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBSGROE06(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: "
                 +dwData["BSGART"].ToString()
            +dwData["BSGMTYP"].ToString();
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DBSGROE01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART: AND BSGMTYP =:BSGMTYP: AND BSGKETTART=:BSGKETTART: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1); 
        }
        public void DBSGROE02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  BSGROE"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }

        public void UpdateBSGROE(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            if(option==0)
            {
                switch(app.company)
                {
                    case "YGR":
                    case "TST":
                    case "UBT":
                    case "SXN":
                    default:
                        UBSGROE01(dwData);
                        break;
                }
            } 
        }
        public void UBSGROE01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BSGROE SET BSGMANDANT=:BSGMANDANT:,BSGART=:BSGART:,BSGMTYP=:BSGMTYP:,BSGLFD=:BSGLFD:,BSGAENDZL=:BSGAENDZL:,BSGAENDBEN=:BSGAENDBEN:,BSGAENDDAT=:BSGAENDDAT:,BSGNEUBEN=:BSGNEUBEN:,BSGNEUDAT=:BSGNEUDAT:,BSGKETTART=:BSGKETTART:,BSGMAXLG=:BSGMAXLG:,BSGMAXGW=:BSGMAXGW:,BSGLOS=:BSGLOS:,BSGANZTB=:BSGANZTB:,BSGLLEIST=:BSGLLEIST:,BSGRLEIST=:BSGRLEIST:,BSGFILLER=:BSGFILLER:"
                 + " WHERE   BSGMANDANT=:BSGMANDANT: AND BSGART=:BSGART: AND BSGMTYP =:BSGMTYP: AND BSGLFD=:BSGLFD: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);

        }
    }
}
